package com.itheima.sh.b_test_02;

import java.util.ArrayList;

public class PhoneTest {
    public static ArrayList<Phone> find(ArrayList<Phone> list, int price , String  color){
        ArrayList<Phone> newlist = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            Phone phone = list.get(i);
            String colour = phone.getColour();
            int price1 = phone.getPrice();
            if (price1>price&&colour.equals(color)){
                newlist.add(phone);
            }
        }
        return newlist;
    }

    public static void main(String[] args) {
        Phone phone = new Phone("小米",3999,"黑色");
        Phone phone1 = new Phone("华为",2999,"黑色");
        Phone phone2 = new Phone("苹果",6999,"彩色");
        Phone phone3 = new Phone("vivo",3999,"红色");

        ArrayList<Phone> phones = new ArrayList<>();
        phones.add(phone);
        phones.add(phone1);
        phones.add(phone2);
        phones.add(phone3);

        ArrayList<Phone> list1=find(phones, 3000,"黑色");
        for (int i = 0; i < list1.size(); i++) {
            Phone phone4 = list1.get(i);
            String brand = phone4.getBrand();
            String colour = phone4.getColour();
            int price = phone4.getPrice();
            System.out.println(brand+colour+price);
        }

    }
}
